﻿using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Text;
using System.Data.Odbc;
using System.Data;
using EzDesk.Apps.Data.Attendance;
using EzDesk.Apps.Model.Attendance;
using EzDesk.Core.Data;
using EzDesk.Utility;
using EzDesk.Utility.Web.Extensions;

namespace EzDesk.DevHelper.DebugLibrary
{

    public class EzDeskAttendanceInitial :EzDeskInitial, IEzDeskInitial
    {
        EzDeskAttendanceContainer attDb = new EzDeskAttendanceContainer();
        private Dictionary<string, Guid> UserIdDictionary = null;
        public EzDeskAttendanceInitial()
        {
            UserIdDictionary = new Dictionary<string, Guid>();
            using (var db = new EzDeskDatabaseContainer())
            {
                var userList = db.UserProfileSet.Select(p => new
                {
                    userId = p.Id,
                    userName = p.UserCode
                });
                userList.Foreach(item => UserIdDictionary.Add(item.userName, item.userId));
            }
        }

        private Guid GetUserIdByUserName(string userName)
        {
            Guid userId = Guid.Empty;
            
            if (!UserIdDictionary.ContainsKey(userName))
            {
                Debug.WriteLine(userName + ": 没找到。");
            }else
            {
                userId = UserIdDictionary[userName];
            }
            return userId;

        }

        public void Initialize()
        {
            Debug.WriteLine("开始配置考勤系统测试环境...");

            //清除签到信息
            CleanUpAttendanceInfo();

            //清除法定假日信息
            CleanUpLegalHolidays();

            //添加法定节假日
            AddLegalHolidaysFor2009();

            //添加历史考勤数据
            //ImportAttendanceDataUntil200911();

            //生成模拟考勤记录
            //GenerateSimAttendanceRecords();

            // 清除假期数据
            CleanUpLeaveInfos();

            //导入假期数据
            //ImportLeaveDataUntil200911();



            //添加考勤使用的分组
            //被考勤的人员组
            // 方案部 所有成员参与考勤

            //接受考勤报告的人员组


        }

        private void CleanUpAttendanceInfo()
        {
            //清除所有签到信息
            attDb.DeleteTable("AttendanceInfoSet");
            attDb.DeleteTable("DayAttendanceEvaluationSet");
            attDb.DeleteTable("DayAttendanceRemarkSet");

            Debug.WriteLine("所有签到信息已经清除！");
        }



        private void ImportLeaveDataUntil200911()
        {            

            Debug.WriteLine("开始导入假期数据");

                string connStr = @"Driver={Microsoft Access Driver (*.mdb)};Dbq=leave.mdb";
                using (OdbcConnection conn = new OdbcConnection(connStr))
                {
                    //导入请假类型
                    conn.Open();
                    string sqlStr = "SELECT * FROM scheduletype";
                    OdbcCommand cmd = new OdbcCommand(sqlStr, conn);
                    OdbcDataReader dr = cmd.ExecuteReader(CommandBehavior.CloseConnection);
                    while (dr.Read())
                    {
                        string typeName = dr["scheduletype"] as string;
                        string remark = dr["remark"] as string;
                        bool isWork = false;
                        if (typeName == "出差" || typeName == "外出")
                        {
                            isWork = true;
                        }

                        attDb.LeaveTypeSet.AddObject(
                            new LeaveType()
                                {
                                    Id = Guid.NewGuid(),
                                    LeaveTypeName = typeName,
                                    Remark = remark,
                                    IsForWork = isWork,
                                });
                    }

                    attDb.SaveChanges();
                    Debug.WriteLine("请假类型信息写入完毕。");


                    Debug.WriteLine("开始导入历史请假信息。");
                    conn.Close();

                    conn.Open();
                    sqlStr = "SELECT * FROM timeschedule";
                    cmd = new OdbcCommand(sqlStr, conn);
                    dr = cmd.ExecuteReader(CommandBehavior.CloseConnection);
                    while (dr.Read())
                    {
                        string userName = dr["username"] as string;
                        string name = dr["name"] as string;

                        Guid userId;
                        userId = GetUserIdByUserName(userName);
                        if (userId == Guid.Empty) continue;

                        string leaveTypeName = dr["scheduletype"] as string;
                        var leaveType = (from l in attDb.LeaveTypeSet
                                         where l.LeaveTypeName == leaveTypeName
                                         select l).FirstOrDefault();
                        if (leaveType == null)
                        {
                            Debug.WriteLine("[验证假期类型] " + leaveType.LeaveTypeName + " 没找到");
                            continue;
                        }


                        DateTime leaveTime = (DateTime)dr["leaveday"];
                        DateTime comebackTime = (DateTime)dr["comebackday"];
                        string description = dr["purpose"] as string;

                        string auditName = dr["auditing_user"] as string;
                        string auditNote = dr["auditing_explain"] as string;
                        int auditing = (int)dr["auditing"];

                        Guid auditUserId;
                        if (UserIdDictionary.ContainsKey(userName))
                        {
                            auditUserId = userId;
                        }else
                        {
                            Debug.Write("[验证AuditUser] " + auditName + " 没找到");
                            continue;
                        }
                        
                        attDb.LeaveInfoSet.AddObject(
                            new LeaveInfo()
                            {
                                Id = Guid.NewGuid(),
                                UserId = userId,
                                Description = description,
                                LeaveTypeId = leaveType.Id,
                                StartTime = leaveTime,
                                EndTime = comebackTime,
                                AuditUserId = auditUserId,
                                AuditNote = auditNote,
                                IsAudited = auditing == 1,
                                CreateOn = leaveTime,
                                IsAgreed = auditing == 1,
                                AuditTime = DateTime.Now
                            }
                            );
                    }
                    attDb.SaveChanges();

                    Debug.WriteLine("历史请假信息导入完成。。");
                }
            
        }

        private void CleanUpLeaveInfos()
        {

            Debug.WriteLine("清除请假数据");
            attDb.DeleteTable("LeaveInfoSet");


            Debug.WriteLine("请假信息已经清除");

            Debug.WriteLine("清除假期类型");
            attDb.DeleteTable("LeaveTypeSet");


            Debug.WriteLine("请假类型已清除。");

            Debug.WriteLine("清除轮休数据");
            attDb.DeleteTable("ExtraShiftSet");

            Debug.WriteLine("轮休数据已清除。");
        }


        private void ImportAttendanceDataUntil200911()
        {
            Debug.WriteLine("开始添加历史考勤信息");
                //从现有数据库中导入截止2009年11月的考勤数据
                // 打开 mdb 数据库
                string connStr = @"Driver={Microsoft Access Driver (*.mdb)};Dbq=kq2011.mdb";
                using (OdbcConnection conn = new OdbcConnection(connStr))
                {
                    conn.Open();
                    for (int i = 1; i <= 11; i++)
                    {
                        string sqlStr = "SELECT * FROM month" + i.ToString();
                        OdbcCommand cmd = new OdbcCommand(sqlStr, conn);
                        OdbcDataReader dr = cmd.ExecuteReader();
                        while (dr.Read())
                        {
                            string userName = dr["username"] as string;
                            string name = dr["name"] as string;

                            Guid userId;
                            userId = GetUserIdByUserName(userName);
                            if (userId == Guid.Empty) continue;

                            DateTime day = (DateTime)dr["day"];
                            int AttendanceTypeValue = 0;
                            DateTime actionTime = DateTime.Today;

                            DateTime comeDate = (DateTime)dr["comedate"];
                            if ((int)comeDate.TimeOfDay.TotalMinutes != 0)
                            {
                                AttendanceTypeValue = 0;
                                actionTime = new DateTime(
                                    day.Year,
                                    day.Month,
                                    day.Day,
                                    comeDate.Hour,
                                    comeDate.Minute,
                                    comeDate.Second
                                    );
                            }

                            DateTime leaveDate = (DateTime)dr["leavedate"];
                            if ((int)leaveDate.TimeOfDay.TotalMinutes != 0)
                            {
                                AttendanceTypeValue = 1;
                                actionTime = new DateTime(
                                    day.Year,
                                    day.Month,
                                    day.Day,
                                    leaveDate.Hour,
                                    leaveDate.Minute,
                                    leaveDate.Second
                                    );
                            }

                            string explain = dr["explain1"] as string;

                            attDb.AttendanceInfoSet.AddObject(
                                new AttendanceInfo()
                                {
                                    Id = Guid.NewGuid(),
                                    UserId = userId,
                                    AttendanceTypeValue = AttendanceTypeValue,
                                    ActionTime = actionTime,
                                    Date = actionTime.Date,
                                    Explanation = explain,
                                    IsAbnormalAttendance = false,
                                }
                            );
                            attDb.SaveChanges();
                        }
                       
                    
                }
            }
        }

        private void AddLegalHolidaysFor2009()
        {

            //添加 2009 年法定假日条目
            var holidayList =
                new List<LegalHoliday>()
                    {
                        new LegalHoliday()
                            {
                                Id = Guid.NewGuid(),
                                StartDate = new DateTime(2009, 1, 1),
                                EndDate = new DateTime(2009, 1, 4),
                                HolidayName = "元旦节",
                                Year = 2009,
                            },
                        new LegalHoliday()
                            {
                                Id = Guid.NewGuid(),
                                StartDate = new DateTime(2009, 1, 25),
                                EndDate = new DateTime(2009, 1, 31),
                                HolidayName = "春节",
                                Year = 2009,
                            },
                        new LegalHoliday()
                            {
                                Id = Guid.NewGuid(),
                                StartDate = new DateTime(2009, 4, 4),
                                EndDate = new DateTime(2009, 4, 6),
                                HolidayName = "清明节",
                                Year = 2009,
                            },
                        new LegalHoliday()
                            {
                                Id = Guid.NewGuid(),
                                StartDate = new DateTime(2009, 5, 1),
                                EndDate = new DateTime(2009, 5, 3),
                                HolidayName = "劳动节",
                                Year = 2009,
                            },
                        new LegalHoliday()
                            {
                                Id = Guid.NewGuid(),
                                StartDate = new DateTime(2009, 5, 28),
                                EndDate = new DateTime(2009, 5, 30),
                                HolidayName = "端午节",
                                Year = 2009,
                            },
                        new LegalHoliday()
                            {
                                Id = Guid.NewGuid(),
                                StartDate = new DateTime(2009, 10, 1),
                                EndDate = new DateTime(2009, 10, 8),
                                HolidayName = "国庆节、中秋节",
                                Year = 2009,
                            }
                    };
            holidayList.ForEach(item => attDb.LegalHolidaySet.AddObject(item));
            attDb.SaveChanges();

            var extraList = new List<ExtraShift>()
                                {
                                    new ExtraShift()
                                        {
                                            Id = Guid.NewGuid(),
                                            StartDate = new DateTime(2009, 1, 24),
                                            EndDate = new DateTime(2009, 1, 24),
                                            ShiftName = "春节调假",
                                            IsNeedWork = true,
                                        },
                                    new ExtraShift()
                                        {
                                            Id = Guid.NewGuid(),
                                            StartDate = new DateTime(2009, 2, 1),
                                            EndDate = new DateTime(2009, 2, 1),
                                            ShiftName = "春节调假",
                                            IsNeedWork = true,
                                        },
                                    new ExtraShift()
                                        {
                                            Id = Guid.NewGuid(),
                                            StartDate = new DateTime(2009, 10, 9),
                                            EndDate = new DateTime(2009, 10, 12),
                                            ShiftName = "集体年假",
                                            IsNeedWork = false,
                                        },
                                };
            extraList.ForEach(item => attDb.ExtraShiftSet.AddObject(item));
            attDb.SaveChanges();
            Debug.WriteLine("2009年法定假日和调休添加完毕");


        }

        private  void CleanUpLegalHolidays()
        {
            Debug.WriteLine("清除法定假日记录");

            attDb.DeleteTable("LegalHolidaySet");
            Debug.WriteLine("清除法定假日记录完成");
        }


        private void GenerateSimAttendanceRecords()
        {

            //加入一些模拟考勤信息

            // 12.10 加班到晚上10点后 早上迟到 下午加班

            // 12.8 加班到晚上10点后_早上正常_下午正常
            attDb.AttendanceInfoSet.AddObject(
                new AttendanceInfo()
                    {
                        Id = Guid.NewGuid(),
                        UserId = new Guid("0c9d7c0c-04a5-4ae2-97a1-d7bbc38f5c66"),
                        Date = new DateTime(2009, 12, 8),
                        ActionTime = new DateTime(2009, 12, 8, 9, 1, 30),
                        AttendanceTypeValue = 0,
                        ////IsExtraWork = false,
                    }
                );
            attDb.AttendanceInfoSet.AddObject(
                new AttendanceInfo()
                    {
                        Id = Guid.NewGuid(),
                        UserId = new Guid("0c9d7c0c-04a5-4ae2-97a1-d7bbc38f5c66"),
                        Date = new DateTime(2009, 12, 8),
                        ActionTime = new DateTime(2009, 12, 8, 23, 20, 20),
                        AttendanceTypeValue = 1,
                        ////IsExtraWork = false,
                    }
                );

            // 12.9 前一天晚上加班到10点后_早上迟到_下午正常
            attDb.AttendanceInfoSet.AddObject(
                new AttendanceInfo()
                    {
                        Id = Guid.NewGuid(),
                        UserId = new Guid("0c9d7c0c-04a5-4ae2-97a1-d7bbc38f5c66"),
                        Date = new DateTime(2009, 12, 9),
                        ActionTime = new DateTime(2009, 12, 9, 10, 32, 30),
                        AttendanceTypeValue = 0,
                        //IsExtraWork = false,
                    }
                );
            attDb.AttendanceInfoSet.AddObject(
                new AttendanceInfo()
                    {
                        Id = Guid.NewGuid(),
                        UserId = new Guid("0c9d7c0c-04a5-4ae2-97a1-d7bbc38f5c66"),
                        Date = new DateTime(2009, 12, 9),
                        ActionTime = new DateTime(2009, 12, 9, 18, 20, 20),
                        AttendanceTypeValue = 1,
                        ////IsExtraWork = false,
                    }
                );

            // 12.10 加班到晚上10点后_早上迟到_下午加班
            attDb.AttendanceInfoSet.AddObject(
                new AttendanceInfo()
                    {
                        Id = Guid.NewGuid(),
                        UserId = new Guid("0c9d7c0c-04a5-4ae2-97a1-d7bbc38f5c66"),
                        Date = new DateTime(2009, 12, 10),
                        ActionTime = new DateTime(2009, 12, 10, 9, 6, 30),
                        AttendanceTypeValue = 0,
                        ////IsExtraWork = false,
                    }
                );
            attDb.AttendanceInfoSet.AddObject(
                new AttendanceInfo()
                    {
                        Id = Guid.NewGuid(),
                        UserId = new Guid("0c9d7c0c-04a5-4ae2-97a1-d7bbc38f5c66"),
                        Date = new DateTime(2009, 12, 10),
                        ActionTime = new DateTime(2009, 12, 10, 23, 20, 20),
                        AttendanceTypeValue = 1,
                        //IsExtraWork = false,
                    }
                );

            // 12.11 前一天加班到晚上10点后 早上晚半小时到 下午加班
            attDb.AttendanceInfoSet.AddObject(
                new AttendanceInfo()
                    {
                        Id = Guid.NewGuid(),
                        UserId = new Guid("0c9d7c0c-04a5-4ae2-97a1-d7bbc38f5c66"),
                        Date = new DateTime(2009, 12, 11),
                        ActionTime = new DateTime(2009, 12, 11, 9, 40, 30),
                        AttendanceTypeValue = 0,
                        //IsExtraWork = false,
                    }
                );
            attDb.AttendanceInfoSet.AddObject(
                new AttendanceInfo()
                    {
                        Id = Guid.NewGuid(),
                        UserId = new Guid("0c9d7c0c-04a5-4ae2-97a1-d7bbc38f5c66"),
                        Date = new DateTime(2009, 12, 11),
                        ActionTime = new DateTime(2009, 12, 11, 23, 20, 20),
                        AttendanceTypeValue = 1,
                        //IsExtraWork = false,
                    }
                );

            // 12.12 周六加班_前一天加班到10点后 早上迟到 下午未考勤
            attDb.AttendanceInfoSet.AddObject(
                new AttendanceInfo()
                    {
                        Id = Guid.NewGuid(),
                        UserId = new Guid("0c9d7c0c-04a5-4ae2-97a1-d7bbc38f5c66"),
                        Date = new DateTime(2009, 12, 12),
                        ActionTime = new DateTime(2009, 12, 12, 10, 29, 30),
                        AttendanceTypeValue = 0,
                        //IsExtraWork = false,
                    }
                );
            //attDb.AttendanceInfoSet.AddObject(
            //    new AttendanceInfo()
            //    {
            //        Id = Guid.NewGuid(),
            //        UserId = new Guid("0c9d7c0c-04a5-4ae2-97a1-d7bbc38f5c66"),
            //        Date = new DateTime(2009, 12, 12),
            //        ActionTime = null,
            //        AttendanceTypeValue = 1,
            //        //IsExtraWork = false,
            //    }
            //    );

            // 12.13 周末加班 早上正常考勤 下午正常考勤
            attDb.AttendanceInfoSet.AddObject(
                new AttendanceInfo()
                    {
                        Id = Guid.NewGuid(),
                        UserId = new Guid("0c9d7c0c-04a5-4ae2-97a1-d7bbc38f5c66"),
                        Date = new DateTime(2009, 12, 13),
                        ActionTime = new DateTime(2009, 12, 13, 10, 29, 30),
                        AttendanceTypeValue = 0,
                        //IsExtraWork = false,
                    }
                );
            attDb.AttendanceInfoSet.AddObject(
                new AttendanceInfo()
                    {
                        Id = Guid.NewGuid(),
                        UserId = new Guid("0c9d7c0c-04a5-4ae2-97a1-d7bbc38f5c66"),
                        Date = new DateTime(2009, 12, 13),
                        ActionTime = new DateTime(2009, 12, 13, 21, 2, 30),
                        AttendanceTypeValue = 1,
                        //IsExtraWork = false,
                    }
                );

            // 12.14 一天未考勤，早上未考勤，下午未考勤
            //attDb.AttendanceInfoSet.AddObject(
            //    new AttendanceInfo()
            //    {
            //        Id = Guid.NewGuid(),
            //        UserId = new Guid("0c9d7c0c-04a5-4ae2-97a1-d7bbc38f5c66"),
            //        Date = new DateTime(2009, 12, 14),
            //        ActionTime = null,
            //        AttendanceTypeValue = 0,
            //        //IsExtraWork = false,
            //    }
            //    );
            //attDb.AttendanceInfoSet.AddObject(
            //    new AttendanceInfo()
            //    {
            //        Id = Guid.NewGuid(),
            //        UserId = new Guid("0c9d7c0c-04a5-4ae2-97a1-d7bbc38f5c66"),
            //        Date = new DateTime(2009, 12, 14),
            //        ActionTime = null,
            //        AttendanceTypeValue = 1,
            //        //IsExtraWork = false,
            //    }
            //    );

            // 12.15早上，早上迟到，下午未考勤
            attDb.AttendanceInfoSet.AddObject(
                new AttendanceInfo()
                    {
                        Id = Guid.NewGuid(),
                        UserId = new Guid("0c9d7c0c-04a5-4ae2-97a1-d7bbc38f5c66"),
                        Date = new DateTime(2009, 12, 15),
                        ActionTime = new DateTime(2009, 12, 15, 8, 21, 20),
                        AttendanceTypeValue = 0,
                        //IsExtraWork = false,
                    }
                );
            //attDb.AttendanceInfoSet.AddObject(
            //    new AttendanceInfo()
            //    {
            //        Id = Guid.NewGuid(),
            //        UserId = new Guid("0c9d7c0c-04a5-4ae2-97a1-d7bbc38f5c66"),
            //        Date = new DateTime(2009, 12, 15),
            //        ActionTime = null,
            //        AttendanceTypeValue = 1,
            //        //IsExtraWork = false,
            //    }
            //    );

            // 12.16早上，早上未考勤，下午正常下班
            //attDb.AttendanceInfoSet.AddObject(
            //    new AttendanceInfo()
            //    {
            //        Id = Guid.NewGuid(),
            //        UserId = new Guid("0c9d7c0c-04a5-4ae2-97a1-d7bbc38f5c66"),
            //        Date = new DateTime(2009, 12, 16),
            //        ActionTime = null,
            //        AttendanceTypeValue = 0,
            //        //IsExtraWork = false,
            //    }
            //    );
            attDb.AttendanceInfoSet.AddObject(
                new AttendanceInfo()
                    {
                        Id = Guid.NewGuid(),
                        UserId = new Guid("0c9d7c0c-04a5-4ae2-97a1-d7bbc38f5c66"),
                        Date = new DateTime(2009, 12, 16),
                        ActionTime = new DateTime(2009, 12, 16, 18, 21, 20),
                        AttendanceTypeValue = 1,
                        //IsExtraWork = false,
                    }
                );



            // 12.17早上，上班迟到，下午早退
            attDb.AttendanceInfoSet.AddObject(
                new AttendanceInfo()
                    {
                        Id = Guid.NewGuid(),
                        UserId = new Guid("0c9d7c0c-04a5-4ae2-97a1-d7bbc38f5c66"),
                        Date = new DateTime(2009, 12, 17),
                        ActionTime = new DateTime(2009, 12, 17, 10, 25, 20),
                        AttendanceTypeValue = 0,
                        //IsExtraWork = false,
                    }
                );
            attDb.AttendanceInfoSet.AddObject(
                new AttendanceInfo()
                    {
                        Id = Guid.NewGuid(),
                        UserId = new Guid("0c9d7c0c-04a5-4ae2-97a1-d7bbc38f5c66"),
                        Date = new DateTime(2009, 12, 17),
                        ActionTime = new DateTime(2009, 12, 17, 16, 21, 20),
                        AttendanceTypeValue = 1,
                        //IsExtraWork = false,
                    }
                );


            // 12.18早上 正常上班, 下午早退
            attDb.AttendanceInfoSet.AddObject(
                new AttendanceInfo()
                    {
                        Id = Guid.NewGuid(),
                        UserId = new Guid("0c9d7c0c-04a5-4ae2-97a1-d7bbc38f5c66"),
                        Date = new DateTime(2009, 12, 18),
                        ActionTime = new DateTime(2009, 12, 18, 8, 40, 20),
                        AttendanceTypeValue = 0,
                        //IsExtraWork = false,
                    }
                );
            attDb.AttendanceInfoSet.AddObject(
                new AttendanceInfo()
                    {
                        Id = Guid.NewGuid(),
                        UserId = new Guid("0c9d7c0c-04a5-4ae2-97a1-d7bbc38f5c66"),
                        Date = new DateTime(2009, 12, 18),
                        ActionTime = new DateTime(2009, 12, 18, 17, 45, 20),
                        AttendanceTypeValue = 1,
                        //IsExtraWork = false,
                    }
                );



            // 12.21 早上迟到，下午正常下班
            attDb.AttendanceInfoSet.AddObject(
                new AttendanceInfo()
                    {
                        Id = Guid.NewGuid(),
                        UserId = new Guid("0c9d7c0c-04a5-4ae2-97a1-d7bbc38f5c66"),
                        Date = new DateTime(2009, 12, 21),
                        ActionTime = new DateTime(2009, 12, 21, 9, 8, 20),
                        AttendanceTypeValue = 0,
                        //IsExtraWork = false,
                    }
                );
            attDb.AttendanceInfoSet.AddObject(
                new AttendanceInfo()
                    {
                        Id = Guid.NewGuid(),
                        UserId = new Guid("0c9d7c0c-04a5-4ae2-97a1-d7bbc38f5c66"),
                        Date = new DateTime(2009, 12, 21),
                        ActionTime = new DateTime(2009, 12, 21, 18, 3, 20),
                        AttendanceTypeValue = 1,
                        //IsExtraWork = false,
                    }
                );

            // 12.22早上 正常上班, 下午正常下班，上班时间在缓冲时间内
            attDb.AttendanceInfoSet.AddObject(
                new AttendanceInfo()
                    {
                        Id = Guid.NewGuid(),
                        UserId = new Guid("0c9d7c0c-04a5-4ae2-97a1-d7bbc38f5c66"),
                        Date = new DateTime(2009, 12, 22),
                        ActionTime = new DateTime(2009, 12, 22, 9, 3, 20),
                        AttendanceTypeValue = 0,
                        //IsExtraWork = false,
                    }
                );
            attDb.AttendanceInfoSet.AddObject(
                new AttendanceInfo()
                    {
                        Id = Guid.NewGuid(),
                        UserId = new Guid("0c9d7c0c-04a5-4ae2-97a1-d7bbc38f5c66"),
                        Date = new DateTime(2009, 12, 22),
                        ActionTime = new DateTime(2009, 12, 22, 18, 2, 20),
                        AttendanceTypeValue = 1,
                        //IsExtraWork = false,
                    }
                );

            // 12.23早上 正常上班, 下午正常下班
            attDb.AttendanceInfoSet.AddObject(
                new AttendanceInfo()
                    {
                        Id = Guid.NewGuid(),
                        UserId = new Guid("0c9d7c0c-04a5-4ae2-97a1-d7bbc38f5c66"),
                        Date = new DateTime(2009, 12, 23),
                        ActionTime = new DateTime(2009, 12, 23, 8, 40, 20),
                        AttendanceTypeValue = 0,
                        //IsExtraWork = false,
                    }
                );
            attDb.AttendanceInfoSet.AddObject(
                new AttendanceInfo()
                    {
                        Id = Guid.NewGuid(),
                        UserId = new Guid("0c9d7c0c-04a5-4ae2-97a1-d7bbc38f5c66"),
                        Date = new DateTime(2009, 12, 23),
                        ActionTime = new DateTime(2009, 12, 23, 18, 3, 20),
                        AttendanceTypeValue = 1,
                        //IsExtraWork = false,
                    }
                );



            #region [ 今日考勤测试数据 ]

            // 添加3个测试员工的今日考勤记录
            // 上午迟到
            attDb.AttendanceInfoSet.AddObject(
                new AttendanceInfo()
                    {
                        Id = Guid.NewGuid(),
                        UserId = new Guid("0c9d7c0c-04a5-4ae2-97a1-d7bbc38f5c66"),
                        Date = DateTime.Today,
                        ActionTime =
                            new DateTime(DateTime.Today.Year, DateTime.Today.Month, DateTime.Today.Day, 9, 40, 20),
                        AttendanceTypeValue = 0,
                        //IsExtraWork = false,
                    }
                );
            // 上午正常上班
            attDb.AttendanceInfoSet.AddObject(
                new AttendanceInfo()
                    {
                        Id = Guid.NewGuid(),
                        UserId = new Guid("0c9d7c0c-04a5-4ae2-97a1-d7bbc38f5c66"),
                        Date = DateTime.Today,
                        ActionTime =
                            new DateTime(DateTime.Today.Year, DateTime.Today.Month, DateTime.Today.Day, 8, 50, 20),
                        AttendanceTypeValue = 0,
                        //IsExtraWork = false,
                    }
                );
            //// 未到
            //attDb.AttendanceInfoSet.AddObject(
            //    new AttendanceInfo()
            //    {
            //        Id = Guid.NewGuid(),
            //        UserId = new Guid("877c3323-17a7-42d1-9d75-402ffc894e63"),
            //        Day = DateTime.Today,
            //        ActionTime = null,
            //        AttendanceTypeValue = 0,
            //        //IsExtraWork = false,
            //    }
            //);


            #endregion

            #region [ 通宵加班测试数据 ]

            // 2010.3.1 申请通宵加班 加班到3.2凌晨 打卡下班 第二天正常打卡

            //attDb.ez_Person_ExtraWorks.AddObject(
            //    new ez_Person_ExtraWork()
            //    {
            //        UserId = new Guid("0c9d7c0c-04a5-4ae2-97a1-d7bbc38f5c66"),
            //        Day = new DateTime(2010, 3, 1),
            //    }
            //    );

            attDb.AttendanceInfoSet.AddObject(
                new AttendanceInfo()
                    {
                        Id = Guid.NewGuid(),
                        UserId = new Guid("0c9d7c0c-04a5-4ae2-97a1-d7bbc38f5c66"),
                        Date = new DateTime(2010, 3, 1),
                        ActionTime = new DateTime(2009, 3, 1, 8, 40, 20),
                        AttendanceTypeValue = 0,
                        //IsExtraWork = false,
                    }
                );


            attDb.AttendanceInfoSet.AddObject(
                new AttendanceInfo()
                    {
                        Id = Guid.NewGuid(),
                        UserId = new Guid("0c9d7c0c-04a5-4ae2-97a1-d7bbc38f5c66"),
                        Date = new DateTime(2009, 3, 1),
                        ActionTime = new DateTime(2009, 3, 1, 23, 59, 00),
                        AttendanceTypeValue = 1,
                        //IsExtraWork = false,
                    }
                );
            attDb.AttendanceInfoSet.AddObject(
                new AttendanceInfo()
                    {
                        Id = Guid.NewGuid(),
                        UserId = new Guid("0c9d7c0c-04a5-4ae2-97a1-d7bbc38f5c66"),
                        Date = new DateTime(2010, 3, 2),
                        ActionTime = new DateTime(2009, 3, 2, 0, 0, 0),
                        AttendanceTypeValue = 0,
                        //IsExtraWork = true,
                    }
                );

            attDb.AttendanceInfoSet.AddObject(
                new AttendanceInfo()
                    {
                        Id = Guid.NewGuid(),
                        UserId = new Guid("0c9d7c0c-04a5-4ae2-97a1-d7bbc38f5c66"),
                        Date = new DateTime(2009, 3, 2),
                        ActionTime = new DateTime(2009, 3, 2, 3, 0, 0),
                        AttendanceTypeValue = 1,
                        //IsExtraWork = true,
                    }
                );

            attDb.AttendanceInfoSet.AddObject(
                new AttendanceInfo()
                    {
                        Id = Guid.NewGuid(),
                        UserId = new Guid("0c9d7c0c-04a5-4ae2-97a1-d7bbc38f5c66"),
                        Date = new DateTime(2010, 3, 2),
                        ActionTime = new DateTime(2009, 3, 2, 8, 0, 0),
                        AttendanceTypeValue = 0,
                        //IsExtraWork = true,
                    }
                );

            attDb.AttendanceInfoSet.AddObject(
                new AttendanceInfo()
                    {
                        Id = Guid.NewGuid(),
                        UserId = new Guid("0c9d7c0c-04a5-4ae2-97a1-d7bbc38f5c66"),
                        Date = new DateTime(2009, 3, 2),
                        ActionTime = new DateTime(2009, 3, 2, 19, 00, 00),
                        AttendanceTypeValue = 1,
                        //IsExtraWork = true,
                    }
                );

            // 2010.3.3 未申请通宵加班 加班到3.4凌晨

            #endregion

            attDb.SaveChanges();


            Debug.WriteLine("添加模拟考勤数据完成");
        }

        #region IEzDeskInitial Members


        public void AddInitializeModule(IEzDeskInitial EzDeskMessageInitial)
        {
            throw new NotImplementedException();
        }

        #endregion
    }
}
